home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / AppleScript / Development Tools / Interfaces / AppleScript 1.1 Interfaces / PInterfaces / AEObjects.p next >
Encoding:
Text File  |  1994-04-08  |  9.3 KB  |  249 lines  |  [TEXT/MPS ]

  1. {———————————————————————————————————————————————————————————————————————————————————}
  2. {                                            
  3.     ©Apple Computer, Inc.  1990, 1991             
  4.           All Rights Reserved.                
  5.  
  6. {[r+,l+,k+,v+,t=4,0=150] Pasmat options}
  7.  
  8.  
  9. {$IFC UNDEFINED UsingIncludes}
  10. {$SETC UsingIncludes := 0}
  11. {$ENDC}
  12.  
  13. {$IFC NOT UsingIncludes}
  14.     UNIT AEObjects;
  15.     INTERFACE
  16. {$ENDC}
  17.  
  18. {$IFC UNDEFINED UsingAEObjects}
  19. {$SETC UsingAEObjects := 1}
  20.  
  21. {$I+}
  22. {$SETC AEObjectIncludes := UsingIncludes}
  23. {$SETC UsingIncludes := 1}
  24. {$IFC UNDEFINED UsingTypes}
  25. {$I $$Shell(PInterfaces)Types.p}
  26. {$ENDC}
  27. {$IFC UNDEFINED UsingMemory}
  28. {$I $$Shell(PInterfaces)Memory.p}
  29. {$ENDC}
  30. {$IFC UNDEFINED UsingOSUtils}
  31. {$I $$Shell(PInterfaces)OSUtils.p}
  32. {$ENDC}
  33. {$IFC UNDEFINED UsingEvents}
  34. {$I $$Shell(PInterfaces)Events.p}
  35. {$ENDC}
  36. {$IFC UNDEFINED UsingEPPC}
  37. {$I $$Shell(PInterfaces)EPPC.p}
  38. {$ENDC}
  39. {$IFC UNDEFINED UsingAppleEvents}
  40. {$I $$Shell(PInterfaces)AppleEvents.p}
  41. {$ENDC}
  42.  
  43. {$SETC UsingIncludes := AEObjectIncludes}
  44.  
  45. CONST
  46.  
  47. { Logical operators: look for them in descriptors of type typeLogicalDescriptor
  48.   with keyword keyAELogicalOperator }
  49.     kAEAND                    =    'AND ';
  50.     kAEOR                    =    'OR  ';
  51.     kAENOT                    =    'NOT ';
  52.  
  53. { Absolute ordinals: look for them in descriptors of type typeAbsoluteOrdinal.
  54.   Possible use is as keyAEKeyData in an object specifier whose keyAEKeyForm
  55.   field is formAbsolutePosition. }
  56.     kAEFirst                =    'firs';
  57.     kAELast                    =    'last';
  58.     kAEMiddle                =    'midd';
  59.     kAEAny                    =    'any ';
  60.     kAEAll                    =    'all ';
  61.  
  62. {  Relative ordinals: look for them in descriptors of type formRelativePosition. }
  63.     kAENext                    =    'next';
  64.     kAEPrevious                =    'prev';
  65.  
  66. {********* Keywords for getting fields out of Object specifier records *********}
  67.     keyAEDesiredClass        =    'want';
  68.     keyAEContainer            =    'from';
  69.     keyAEKeyForm            =    'form';
  70.     keyAEKeyData             =     'seld';
  71.  
  72.  
  73. {********* Keywords for getting fields out of Range specifier records *********}
  74.     keyAERangeStart            =    'star';        { These are the only two fields in the range desc }
  75.     keyAERangeStop            =    'stop';
  76.     
  77. {********* Possible values for the keyAEKeyForm field of an object specifier *********}
  78. { Remember that this set is an open-ended one.  The OSL makes assumptions about some of them,
  79.   but nothing in the grammar says you can't define your own }
  80.     formAbsolutePosition     =    'indx' ;    { e.g., 1st, -2nd (= 2nd from end) }
  81.     formRelativePosition    =    'rele' ;    { next, previous }
  82.     formTest                =    'test' ;    { A logical or a comparison }
  83.     formRange                =    'rang' ;    { Two arbitrary objects and everything in between }
  84.     formPropertyID            =    'prop' ;    { Key data is a 4-char property name }
  85.     formName                =    'name' ;    { Key data may be of type 'TEXT' }
  86.  
  87. {************* Various relevant types ***************}
  88. { Some of these tend to be paired with certain of the forms above.  Where this
  89.   is the case comments indicating the form(s) follow. }
  90.     typeObjectSpecifier     =     'obj ';        { keyAEContainer will often be one of these }
  91.     typeObjectBeingExamined =    'exmn';        { Another possible value for keyAEContainer }
  92.     typeCurrentContainer    =    'ccnt';        { Another possible value for keyAEContainer }
  93.     typeToken                =    'toke';        { Substituted for 'ccnt' before accessor called }
  94.  
  95.     typeRelativeDescriptor     =    'rel ';        { formRelativePosition }
  96.     typeAbsoluteOrdinal     =    'abso';        { formAbsolutePosition }
  97.     typeIndexDescriptor        =    'inde';        { formAbsolutePosition }
  98.     typeRangeDescriptor     =     'rang';        { formRange }
  99.     typeLogicalDescriptor    =     'logi';        { formTest is this or typeCompDescriptor }
  100.     typeCompDescriptor        =    'cmpd';        { formTest is this or typeLogicalDescriptor }
  101.     
  102. {************* various relevant keywords ***************}
  103.     keyAECompOperator        =    'relo';        { Relates two terms: '=', '<=', etc. }
  104.     keyAELogicalTerms        =    'term';        { An AEList of terms to be related by 'logc' below }
  105.     keyAELogicalOperator    =    'logc';        { kAEAND,  kAEOR or kAENOT }
  106.     keyAEObject1            =    'obj1';        { One of two objects in a term; must be object specifier }
  107.     keyAEObject2            =    'obj2';        { The other object; may be a simple descriptor or obj. spec. }
  108.  
  109.  
  110. {*********** Special Handler selectors for OSL Callbacks **************}
  111. { You don't need to use these unless you are not using AESetObjectCallbacks. }
  112.     keyDisposeTokenProc        =    'xtok';
  113.     keyAECompareProc         =     'cmpr';
  114.     keyAECountProc             =     'cont';
  115.     keyAEMarkTokenProc         =     'mkid';
  116.     keyAEMarkProc             =     'mark';
  117.     keyAEAdjustMarksProc     =     'adjm';
  118.     keyAEGetErrDescProc     =     'indc';
  119.  
  120. {*********** Error codes **************}
  121. { OSL error codes: AEM proper uses up to -1719}
  122.     errAEImpossibleRange    =    -1720 ;        { A range like 3rd to 2nd, or 1st to all. }
  123.     errAEWrongNumberArgs    =    -1721 ;        { Logical op kAENOT used with other than 1 term }
  124.  
  125.     errAEAccessorNotFound     =    -1723 ;        { Accessor proc matching wantClass and containerType
  126.                                             ...or wildcards not found }
  127.     errAENoSuchLogical        =    -1725 ;     { Something other than AND, OR, or NOT }
  128.     errAEBadTestKey            =    -1726 ;        { Test is neither typeLogicalDescriptor
  129.                                             ...nor typeCompDescriptor }
  130.     errAENotAnObjSpec        =    -1727 ;     { Param to AEResolve not of type 'obj ' }
  131.     errAENoSuchObject        =    -1728 ;     { e.g.,: specifier asked for the 3rd, but there are only 2.
  132.                                             ...Basically, this indicates a run-time resolution error. }
  133.     errAENegativeCount        =    -1729 ;        { CountProc returned negative value }
  134.     errAEEmptyListContainer    =    -1730 ;        { Attempt to pass empty list as container to accessor }
  135.     
  136. { Possible values for flags parameter to AEResolve.  They're additive }
  137.     kAEIDoMinimum            =    $0000 ;
  138.     kAEIDoWhose                =    $0001 ;
  139.     kAEIDoMarking            =    $0004 ;
  140.  
  141.  
  142. { You only care about the constants that follow if you're doing your own whose
  143.   clause resolution }
  144.     typeWhoseDescriptor        =    'whos';
  145.     formWhose                =    'whos';
  146.     typeWhoseRange            =    'wrng';
  147.     keyAEWhoseRangeStart    =    'wstr';
  148.     keyAEWhoseRangeStop        =    'wstp';
  149.     keyAEIndex                =    'kidx';
  150.     keyAETest                =    'ktst';
  151.  
  152.  
  153. TYPE
  154.     ccntTokenRecord = RECORD        { Used for rewriting tokens in place of 'ccnt' descriptors.        }
  155.         tokenClass: DescType ;        { This record is only of interest to those who, when they...    }
  156.         token:        AEDesc ;        { ...get ranges as key data in their accessor procs, choose...    }
  157.         END ;                        { ...resolve them manually rather than call AEResolve again.    }
  158.     ccntTokenRecPtr = ^ccntTokenRecord ;
  159.     ccntTokenRecHandle = ^ccntTokenRecPtr ;
  160.  
  161.     DescPtr = ^AEDesc ;
  162.     DescHandle = ^DescPtr ;
  163.  
  164.     AccessorProcPtr= ProcPtr;
  165.  
  166. {——————————————————————————————— PUBLIC PROCEDURES —————————————————————————————————}
  167.  
  168. { Not done by inline, but by direct linking into code.  It sets up the pack
  169.   such that further calls can be via inline }
  170. FUNCTION  AEObjectInit                                    : OSErr ;
  171.  
  172.  
  173. FUNCTION AESetObjectCallbacks(myCompareProc,
  174.                             myCountProc,
  175.                             myDisposeTokenProc,
  176.                             myGetMarkTokenProc,                    { called when mark (below) is true }
  177.                             myMarkProc,                            { called when mark (below) is true }
  178.                             myAdjustMarksProc,                    { called when mark (below) is true }
  179.                             myGetErrDescProc: ProcPtr)    : OSErr;{ called to report an error descriptor }
  180. INLINE $303C, $0E35, $A816;        { = move.w    #$E35,d0 \n _Pack8 }
  181.  
  182.  
  183.  
  184.  
  185. FUNCTION  AEResolve            (    objectSpecifier:    AEDesc;
  186.                                 callbackFlags:        INTEGER ;        { see above for possible values }
  187.                                   VAR theToken:        AEDesc)    : OSErr;
  188. INLINE $303C, $0536, $A816;        { = move.w    #$E35,d0 \n _Pack8 }
  189.  
  190.  
  191. FUNCTION AEInstallObjectAccessor(desiredClass:         DescType;
  192.                                    containerType:         DescType;
  193.                                    theAccessor:         AccessorProcPtr;
  194.                                    accessorRefcon:     LONGINT;
  195.                                    isSysHandler:         BOOLEAN): OSErr;
  196. INLINE $303C, $0937, $A816;        { = move.w    #$E35,d0 \n _Pack8 }
  197.  
  198. FUNCTION AERemoveObjectAccessor(    desiredClass:         DescType ;
  199.                                     containerType:         DescType ;
  200.                                     theAccessor:         AccessorProcPtr ;
  201.                                     isSysHandler:         BOOLEAN ) : OSErr ;
  202. INLINE $303C, $0738, $A816;        { = move.w    #$E35,d0 \n _Pack8 }
  203.  
  204. FUNCTION AEGetObjectAccessor(    desiredClass:         DescType;
  205.                                 containerType:         DescType;
  206.                                 VAR theAccessor:     AccessorProcPtr;
  207.                                 VAR accessorRefcon: LONGINT;
  208.                                 isSysHandler:         BOOLEAN): OSErr;
  209. INLINE $303C, $0939, $A816;        { = move.w    #$E35,d0 \n _Pack8 }
  210.  
  211. FUNCTION AEDisposeToken( VAR theToken: AEDesc ): OSErr ;
  212. INLINE $303C, $023A, $A816;        { = move.w    #$E35,d0 \n _Pack8 }
  213.  
  214. FUNCTION AECallObjectAccessor(    desiredClass:        DescType ;
  215.                                 containerToken:        AEDesc ;
  216.                                 containerClass:        DescType ;
  217.                                 keyForm:            DescType ;
  218.                                 keyData:            AEDesc ;
  219.                                 VAR theToken:        AEDesc): OSErr ;
  220. INLINE $303C, $0C3B, $A816;        { = move.w    #$E35,d0 \n _Pack8 }
  221.  
  222. {
  223. Here are the interfaces your callback procs must be written to:
  224.  
  225. FUNCTION MyCompareProc( comparisonOperator: DescType; theObject: AEDesc; descOrObj:AEDesc;
  226.         VAR result: BOOLEAN ): OSErr;
  227. FUNCTION MyCountProc( desiredType: DescType; containerClass: DescType; theContainer: AEDesc;
  228.         VAR result: LongInt ): OSErr;
  229. FUNCTION MyGetMarkToken( containerToken: AEDesc; containerClass: DescType; VAR result: AEDesc ): OSErr;
  230. FUNCTION MyMark( theToken: AEDesc; markToken: AEDesc; markCount: LONGINT ): OSErr;
  231. FUNCTION MyAdjustMarks( newStart,newStop: LongInt; markToken: AEDesc ): OSErr;
  232. FUNCTION MyDisposeToken( VAR unneededToken: AEDesc ) : OSErr ;
  233. FUNCTION MyGetErrDescProc( VAR errDescPtr: DescPtr ) : OSErr ;
  234.  
  235. FUNCTION MyObjectAccessor( desiredClass: DescType; containerToken: AEDesc;
  236.         containerClass: DescType; keyForm: DescType;
  237.         keyData: AEDesc; VAR theToken: AEDesc; theRefcon: LongInt; ): OSErr;
  238.  
  239. You'll probably want to have a number of these last ones.
  240. A proc that finds a line within a document should be installed with 'line' and 'docu'
  241. as the desiredClass and containerClass fields in the call to AEInstallObjectHandler().
  242. }
  243.  
  244. {$ENDC}    { UsingAEObjects }
  245.  
  246. {$IFC NOT UsingIncludes}
  247. END.
  248. {$ENDC}
  249.